﻿///***************************************************************
/// 시  스  템 : Updms.Cfg.Dac
/// 단위시스템 : CFG
/// 계      층 : Data Access Layer
/// 프로그램명 : Cfg_Dac_UPDMS_OBJECT
/// 파  일  명 : Cfg_Dac_UPDMS_OBJECT.cs
/// 설      명 : 소스생성기
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-11-28 송시명   최초 작성
///***************************************************************
using System.Data;
using System.Data.SqlClient;
using System.EnterpriseServices;
using System.Reflection;
using System.Runtime.InteropServices;

using SMFramework.Data;

namespace Updms.Cfg.Dac
{
	[ComVisible(true)]
	[Transaction(TransactionOption.Supported)]
	[JustInTimeActivation(true)]
	public class Cfg_Dac_UPDMS_OBJECT : Base.AppFramework.DacBase
	{
		public Cfg_Dac_UPDMS_OBJECT()
		{
			
		}

		#region NT [GetDatabaseInfo]
		/// <summary>
		/// 데이터베이스 정보조회
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public DataSet GetDatabaseInfo()
		{
			string ls_curr_method = MethodBase.GetCurrentMethod().DeclaringType.ToString() + " - " + MethodBase.GetCurrentMethod().ToString();
			string strSql = "select [name] AS DB from sys.databases where [name] NOT IN ('master','tempdb','model','msdb','ReportServer','ReportServerTempDB')";	
			
			DataSet ds = new DataSet();
			return _agent.Fill(strSql, "UPDMS_OBJECT", ds, null, CommandType.Text, ls_curr_method);
		}
		
		#endregion

		#region NT [GetTableInfo]
		/// <summary>
		/// 테이블 정보조회
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public DataSet GetTableInfo(DataPack lo_dp)
		{
			string ls_curr_method = MethodBase.GetCurrentMethod().DeclaringType.ToString() + " - " + MethodBase.GetCurrentMethod().ToString();
			string strSql = "exec sp_tables @table_name = '" + lo_dp["ls_database"].ToString() + "_%'";

			DataSet ds = new DataSet();
			return _agent.Fill(strSql, "UPDMS_OBJECT", ds, null, CommandType.Text, ls_curr_method);
		}

		#endregion

		#region NT [SelectProcess]
		/// <summary>
		/// 필드 정보조회
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public DataSet SelectProcess(DataPack lo_dp)
		{
			string ls_curr_method = MethodBase.GetCurrentMethod().DeclaringType.ToString() + " - " + MethodBase.GetCurrentMethod().ToString();
			string strSql = "exec sp_columns " + lo_dp["ls_table"].ToString() + "";

			DataSet ds = new DataSet();
			return _agent.Fill(strSql, "UPDMS_OBJECT", ds, null, CommandType.Text, ls_curr_method);
		}

		#endregion

		#region NT [GetSpColumnsEx]
		/// <summary>
		/// 필드 정보조회(sp_columns확장)
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public DataSet GetSpColumnsEx(DataPack lo_dp)
		{
			string strSql = "usp_UPDMS_CFG_Get_Sp_Columns_Ex";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();

			DataSet ds = new DataSet();
			return _agent.Fill(strSql, "UPDMS_OBJECT", ds, paramArray, CommandType.StoredProcedure);
		}

		#endregion

	}
}
